package ke05;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Date;

public class SerializationDemo {

	public static void main(String[] args) throws IOException, ClassNotFoundException {
		
		Date date = new Date();
		Student s = new Student("Herbert", 123, "Informatik");
		
		FileOutputStream fout = new FileOutputStream("x.dat");
		ObjectOutputStream oout = new ObjectOutputStream(fout);
		
		oout.writeObject(date);
		oout.writeObject(s);
		
		FileInputStream fin = new FileInputStream("x.dat");
		ObjectInputStream oin = new ObjectInputStream(fin);
		
		Date read = (Date)oin.readObject();
		Student s1 = (Student) oin.readObject();
		
		System.out.println(read);
		System.out.println(s1.getStudyID());
	}

}
